{% extends "base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin textfilters static ietf_filters %}
{% block pagehead %}
    <link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
{% endblock %}
{% block title %}Mail recipients{% endblock %}
{% block content %}
    {% origin %}
    <h1>Mail recipients</h1>
    <table class="my-3 table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col" data-sort="recipient">Recipient</th>
                <th scope="col" data-sort="triggers">Triggers</th>
                <th scope="col" data-sort="template">Template</th>
                <th scope="col" data-sort="code">Code</th>
            </tr>
        </thead>
        {% if recipients %}
            <tbody>
                {% for recipient in recipients %}
                    <tr>
                        <td>
                            <a href="{% url 'ietf.mailtrigger.views.show_recipients' recipient.slug %}" title="{{ recipient.desc }}">{{ recipient.slug }}</a>
                        </td>
                        <td>
                            {% for mailtrigger in recipient.used_in_to.all %}
                                <a href="{% url 'ietf.mailtrigger.views.show_triggers' mailtrigger.slug %}"
                                   title="{{ mailtrigger.desc }}">
                                    {{ mailtrigger.slug }}</a>{% if not forloop.last %},{% endif %}
                            {% endfor %}
                            {% if recipient.used_in_to.exists and recipient.used_in_cc.exists %},{% endif %}
                            {% for mailtrigger in recipient.used_in_cc.all %}
                                <a href="{% url 'ietf.mailtrigger.views.show_triggers' mailtrigger.slug %}"
                                   title="{{ mailtrigger.desc }}">
                                    {{ mailtrigger.slug }}</a>{% if not forloop.last %},{% endif %}
                            {% endfor %}
                        </td>
                        <td>
                            {% if recipient.template %}
                                <pre><code>{{ recipient.template|escape }}</code></pre>
                            {% endif %}
                        </td>
                        <td>
                            {% if recipient.code %}
                                <pre><code>{{ recipient.code|escape }}</code></pre>
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            </tbody>
        {% endif %}
    </table>
{% endblock %}
{% block js %}
    <script src="{% static "ietf/js/list.js" %}"></script>
{% endblock %}